package com.example.boot_6.map;

import java.util.*;

public class Map_3 {
    public static void main(String[] args) {
        HashMap<Object, Object> map = new HashMap<>();
        map.put("k1", "v");
        map.put("k2", "v");
        map.put("k3", "v");
        map.put("k4", "v2");
        map.put("k5", "v3");
        map.put("k6", "v3");

        Object put = map.put("k1", "hhh");
        System.out.println(put);
        HashMap<Object, Object> map1 = new HashMap<>();
        //存放重复的value值
        List<Object> list = new ArrayList<>();
        //存放去重后的key值
        List<Object> listkey = new ArrayList<>();
        //置换map中的k,v 值
        Iterator<Map.Entry<Object, Object>> iterator = map.entrySet().iterator();
        while (iterator.hasNext()){
            Map.Entry<Object, Object> next = iterator.next();
            if (map1.get(next.getValue())==null) {
                map1.put(next.getValue(), next.getKey());
            }else {
                list.add(next.getValue());
            }
        }
        System.out.println(list);
    }
}
